package cn.raven.service.impl;

import cn.raven.entity.Product;
import cn.raven.entity.Store;
import cn.raven.feign.StoreFeignClient;
import cn.raven.mapper.ProductMapper;
import cn.raven.service.IProductService;
import cn.raven.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.jws.Oneway;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class ProductServiceImpl implements IProductService {
    @Autowired
    private ProductMapper productMapper;
    @Autowired
    private StoreFeignClient feignClient;
    @Override
    @Transactional
    public AjaxResult add(Product product) {
        productMapper.add(product);
        Store store = new Store();
        store.setProductId(product.getId());
        store.setNumber(product.getNumber());
        return feignClient.add(store);
    }
}
